using DiLu.Expansion.File.Operates.LocalDisk.Configs;

namespace DiLu.Expansion.File.Operates.LocalDisk;

/// <summary>
///     获取本地磁盘文件
/// </summary>
public static class GetLocalDiskFile
{
    /// <summary>
    ///     获取本地磁盘文件
    /// </summary>
    /// <param name="config">获取本地磁盘文件流配置</param>
    /// <returns></returns>
    public static async ValueTask<Stream> GetAsync(this GetLocalDiskFileStreamConfig config)
    {
        if (!System.IO.File.Exists(config.FileFullPath)) return null;
        await Task.Delay(0);
        return new FileStream(config.FileFullPath, FileMode.Open, FileAccess.Read, FileShare.Read);
    }
}